package com.hibikiluler.javalearning.util;

import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.io.Serializable;
import java.util.List;

/**
 * 分页结果
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class PageResult extends Result implements Serializable {
    @ApiModelProperty("总记录数")
    private long total;  //总记录数

    @ApiModelProperty("分页的数据列表")
    private List<?> rows; //分页的数据

    public PageResult(long total, List<?> list){
        this.setFlag(true);
        this.setMessage("分页查询成功");
        this.total = total;
        this.rows = list;
    }

    /**
     * 返回分页数据
     * @param total
     * @param list
     * @return
     */
    public static Result pageResult(long total, List<?> list) {
        return new PageResult(total,list);
    }
}
